package com.epam.giorgadze.task3.factory;

import com.epam.giorgadze.task3.entity.plane_type.CargoPlane;
import com.epam.giorgadze.task3.entity.plane_type.PassengerPlane;
import com.epam.giorgadze.task3.entity.plane_type.Plane;

import java.util.Random;

/**
 * User: Luka
 * Date: 06.02.14
 * Time: 11:49
 */
public class PlaneFactory {
    public enum Planes {CARGO, PASSENGER}

    public static Plane createRandomPlane(Planes p, String name, String name1, String email, String address) {
        Random rand = new Random();
        switch (p) {
            case CARGO: {
                Plane plane = new CargoPlane(PlaneModelFactory.createPlaneModel(name, name1, email, address),
                        rand.nextDouble() * 50 + 0.1, rand.nextDouble() * 50 + 0.1, rand.nextDouble() * 50 + 0.1,
                        rand.nextDouble() * 50 + 0.1, rand.nextDouble() * 100 + 0.1);
                ;
                return plane;
            }
            case PASSENGER: {
                Plane plane = new PassengerPlane(PlaneModelFactory.createPlaneModel(name, name1, email, address),
                        rand.nextDouble() * 50 + 0.1, rand.nextDouble() * 50 + 0.1,
                        rand.nextDouble() * 50 + 0.1, rand.nextDouble() * 50 + 0.1, rand.nextInt(100));
                return plane;
            }
            default:
                throw new IllegalArgumentException();
        }
    }
}
